package com.xnfh.home.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.xnfh.framework.bean.RecordsBean
import com.xnfh.home.R
import com.xnfh.home.databinding.ItemFieldDynameicsBinding
import com.xnfh.image.ImageHelper
import com.xnfh.image.ImageUrl

/**
 * @Description:俱乐部 田间反馈 item
 * @Author: ziheng
 * @CreateDate: 2023/10/11 7:15 PM
 * @UpdateUser: ziheng
 * @UpdateDate: 2023/10/11 7:15 PM
 * @UpdateRemark: 更新说明
 */
class FieldDynameicsAdapter :
    BaseQuickAdapter<RecordsBean, BaseDataBindingHolder<ItemFieldDynameicsBinding>>(R.layout.item_field_dynameics) {
    override fun convert(
        holder: BaseDataBindingHolder<ItemFieldDynameicsBinding>,
        item: RecordsBean
    ) {
        val dataBinding = holder.dataBinding
        holder.setText(R.id.item_filed_dyname_dk_name, item.fieldName)
        holder.setText(R.id.item_filed_dyname_city, item.pname + item.cname + item.dname)
        holder.setText(R.id.item_filed_dyname_data, item.feedbackTime)
        holder.setText(R.id.item_field_dynameics_name, item.typeName)
        holder.setText(R.id.item_field_dynameics_connect, item.feedbackContentText)
        if (item.images.isNotEmpty()) {
            holder.setGone(R.id.item_field_dynameics_linear_img, false)
            ImageHelper.instance.loadNetImg(context,ImageUrl.BASEURL+item.images[0],dataBinding?.itemFieldDynameicsOneImg,
                com.xnfh.common.R.mipmap.image_error, com.xnfh.common.R.mipmap.image_error)
            if (item.images.size > 1) {
                ImageHelper.instance.loadNetImg(context,ImageUrl.BASEURL+item.images[1],dataBinding?.itemFieldDynameicsTwoImg,
                    com.xnfh.common.R.mipmap.image_error, com.xnfh.common.R.mipmap.image_error)
            }
            if (item.images.size > 2) {
                ImageHelper.instance.loadNetImg(context,ImageUrl.BASEURL+item.images[2],dataBinding?.itemFieldDynameicsThreeImg,
                    com.xnfh.common.R.mipmap.image_error, com.xnfh.common.R.mipmap.image_error)
            }
        } else {
            holder.setGone(R.id.item_field_dynameics_linear_img, true)
        }
        dataBinding?.itemFieldDynameicsOneImg?.setOnClickListener {
        }
        dataBinding?.itemFieldDynameicsTwoImg?.setOnClickListener {
        }
        dataBinding?.itemFieldDynameicsThreeImg?.setOnClickListener {
        }
    }


}